#ifndef SPA_QUERY_PREPROCESSOR_H
#define SPA_QUERY_PREPROCESSOR_H


#include <set>
#include <map>
#include <string>
#include <fstream>
#include <iostream>
#include <time.h>

#include "QueryTypes.h"
#include "MyTimer.h"
#include "ParentHandle.h"
#include "FollowsHandle.h"
#include "UsesHandle.h"
#include "ModifiesHandle.h"
#include "NextHandle.h"
#include "CallsHandle.h"
#include "AffectsHandle.h"

class QueryPreprocessor
{
	private:
		std::map<std::string, int> _synonyms;
		std::map<std::string, unsigned __int64> _heuristics;

		ParentHandle* _parenthandle;
		FollowsHandle* _followshandle;
		UsesHandle* _useshandle;
		ModifiesHandle* _modifieshandle;
		NextHandle* _nexthandle;
		CallsHandle* _callshandle;
		AffectsHandle* _affectshandle;

		query_tree _tree;
		unsigned __int64 ScoreRelation( query_relation& relation );
		

	public:
		QueryPreprocessor();
		~QueryPreprocessor();
		void calculateHeuristicsValue();
		void Preprocess( query_tree& tree );
		void Update( std::string synonym, int value );
		bool DequeueRelation( query_relation& relation );
};

#endif